import { Route, Redirect } from 'react-router-dom'
import { isAuth } from '@/utils'
import { message } from 'antd'

function AuthRoute (props) {
  const { component: Component, ...otherProps } = props
  return (
    <Route
      {...otherProps}
      render={() => {
        if (isAuth()) {
          return <Component />
        } else {
          message.error('请先登录')
          return <Redirect to='/login'></Redirect>
        }
      }}
    ></Route>
  )
}
export default AuthRoute
